quartz: Fix garbage content when windows are initially mapped
authorKristian Rietveld <kris@lanedo.com>
Fri, 28 Sep 2012 04:50:13 +0000 (06:50 +0200)
committerMichael Natterer <mitch@gimp.org>
Fri, 28 Sep 2012 08:11:16 +0000 (10:11 +0200)
The garbage would be visible if any widget enabled the toplevel
NSView's CALayer in order to do custom native rendering.
(cherry picked from commit 92ea94af5f1a4d0970628b58997192ccf74cab36)

gdk/quartz/GdkQuartzView.c

index d2f791c4f4c22a08f03be26042224cb21ef779ed..49553477101961f48a51303b7dc1cb417667ed96 100644 (file)
   if (NSEqualRects (rect, NSZeroRect))
     return;
 
+  if (!GDK_WINDOW_IS_MAPPED (gdk_window))
+    {
+      /* If the window is not yet mapped, clip_region_with_children
+       * will be empty causing the usual code below to draw nothing.
+       * To not see garbage on the screen, we draw an aesthetic color
+       * here. The garbage would be visible if any widget enabled
+       * the NSView's CALayer in order to add sublayers for custom
+       * native rendering.
+       */
+      [NSGraphicsContext saveGraphicsState];
+
+      [[[self window] backgroundColor] setFill];
+      [NSBezierPath fillRect:rect];
+
+      [NSGraphicsContext restoreGraphicsState];
+
+      return;
+    }
+
   /* Clear our own bookkeeping of regions that need display */
   if (impl->needs_display_region)
     {